class Factory {
    public Fruit createFruit(String code) {
        switch(code.toUpperCase()) {
            case "A": return new Apple();
            case "B": return new Banana();
            default: throw new IllegalArgumentException("Invalid fruit code");
        }
    }
}